package hhh.com.choose_class;

import android.os.Bundle;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Main2Activity extends AppCompatActivity implements View.OnClickListener {
    Button bt_check;
    EditText et_name;
    String name;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        bt_check = (Button) findViewById(R.id.bt_check);
        et_name = (EditText) findViewById(R.id.et_name);

        bt_check.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bt_check:
                name = et_name.getText().toString().trim();
                if(name.equals("java")){
                    Toast.makeText(Main2Activity.this,"您的java成绩为90分",Toast.LENGTH_SHORT).show();
                }
                else if(name.equals("计算机基础")){
                    Toast.makeText(Main2Activity.this,"您的计算机基础课程成绩为80分",Toast.LENGTH_SHORT).show();
                }
                else if(name.equals("数据结构")){
                    Toast.makeText(Main2Activity.this,"您的数据结构课程成绩为95分",Toast.LENGTH_SHORT).show();
                }
                else if(name.equals("C语言")){
                    Toast.makeText(Main2Activity.this,"您的C语言课程成绩为85分",Toast.LENGTH_SHORT).show();
                }else {
                    Toast.makeText(Main2Activity.this,"无此课程的成绩信息！",Toast.LENGTH_SHORT).show();
                }
                break;
        }
    }
}
